// cubedoc.cpp : implementation of the CGLDoc class
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.

#include "stdafx.h"
#include "Sample.h"

#include "GLDoc.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGLDoc

IMPLEMENT_DYNCREATE(CGLDoc, CDocument)

BEGIN_MESSAGE_MAP(CGLDoc, CDocument)
	//{{AFX_MSG_MAP(CGLDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGLDoc construction/destruction

CGLDoc::CGLDoc()
{
	// TODO: add one-time construction code here

}

CGLDoc::~CGLDoc()
{
}

BOOL CGLDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	HRESULT hr = S_OK;
	CComPtr<GLObjectsLib::ICube> pCube1;
	hr = pCube1.CoCreateInstance(__uuidof(GLObjectsLib::Cube));
	pCube1->Init(1.0f, 1.0f, 3.0f + 3.0f / 2.0f);
	m_glObjects.insert(m_glObjects.begin(),(CComPtr<GLObjectsLib::IGLObject>)pCube1);
	CAspector::Instance()->InstallAdvicesForCOM(pCube1);

	CComPtr<GLObjectsLib::ICube> pCube2;
	pCube2.CoCreateInstance(__uuidof(GLObjectsLib::Cube));
	pCube2->Init(-0.5f, -0.5f, 3.0f + 3.0f / 2.0f );
	m_glObjects.insert(m_glObjects.begin(),(CComPtr<GLObjectsLib::IGLObject>)pCube2);
	CAspector::Instance()->InstallAdvicesForCOM(pCube2);

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CGLDoc serialization

void CGLDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CGLDoc diagnostics

#ifdef _DEBUG
void CGLDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CGLDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CGLDoc commands
